﻿using System;
using System.Collections;
using GeoAPI.Geometries;

namespace NetTopologySuite.Utilities
{
	public class CoordinateCompare : IComparer
	{
		public int Compare(object x, object y)
		{
			if (x is Coordinate && y is Coordinate)
			{
				Coordinate coordinate = (Coordinate)x;
				Coordinate coordinate2 = (Coordinate)y;
				int result;
				if (coordinate.X < coordinate2.X)
				{
					result = -1;
				}
				else if (coordinate.X > coordinate2.X)
				{
					result = 1;
				}
				else if (coordinate.Y < coordinate2.Y)
				{
					result = -1;
				}
				else if (coordinate.Y > coordinate2.Y)
				{
					result = 1;
				}
				else
				{
					result = 0;
				}
				return result;
			}
			throw new ArgumentException("Wrong arguments type: Coordinate expected");
		}
	}
}
